package C_Paper;

public class C100_16 {
    public static void main(String[] args) {
        wq(new int[]{0, 5 ,8, 9 ,9 ,10}, new int[]{5 ,0 ,9, 9, 9 ,8});
    }
    public static void wq(int[] x,int[] y){
        int[][] qp = new int[19][19];
        for (int i = 0; i < x.length; i+=2) {
            qp[x[i]][x[i+1]] = 1;
        }
        for (int i = 0; i < y.length; i+=2) {
            qp[y[i]][y[i+1]] = 1;
        }
        for (int i = 0; i < 19; i++) {
            for (int j = 0; j < 19; j++) {
                System.out.print(qp[i][j]+" ");
            }
            System.out.println();
        }
        int xq = 0;
        int yq = 0;
        for (int i = 0; i < x.length; i+=2) {
            //上
            if (x[i] - 1 >= 0 &&  qp[x[i] - 1][x[i + 1]] == 0) {
                xq += 1;
                qp[x[i] - 1][x[i + 1]] = -1;
            }
            //下
            if (x[i] + 1 <= 18 && qp[x[i] + 1][x[i + 1]] == 0) {
                xq += 1;
                qp[x[i] + 1][x[i + 1]] = -1;
            }
            //左
            if (x[i+1] - 1 >= 0 && qp[x[i]][x[i + 1] - 1] == 0) {
                xq += 1;
                qp[x[i]][x[i + 1] - 1] = -1;
            }
            //右
            if (x[i+1] + 1 <= 18 && qp[x[i]][x[i + 1] + 1] == 0) {
                xq += 1;
                qp[x[i]][x[i + 1] + 1] = -1;
            }
        }
        System.out.println(xq);
        for (int i = 0; i < 19; i++) {
            for (int j = 0; j < 19; j++) {
                System.out.print(qp[i][j]+" ");
            }
            System.out.println();
        }
        for (int i = 0; i < y.length; i+=2) {
            //上
            if (y[i] - 1 >= 0) {
                yq += qp[y[i] - 1][y[i + 1]] <= 0 ? 1 : 0;
                qp[y[i] - 1][y[i + 1]] = -1;
            }
            //下
            if (y[i] + 1 <= 18) {
                yq += qp[y[i] + 1][y[i + 1]] <= 0 ? 1 : 0;
                qp[y[i] + 1][y[i + 1]] = -1;
            }
            //左
            if (y[i+1] - 1 >= 0) {
                yq += qp[y[i]][y[i + 1] - 1] <= 0 ? 1 : 0;
                qp[y[i]][y[i + 1] - 1] = -1;
            }
            //右
            if (y[i+1] + 1 <= 18) {
                yq += qp[y[i]][y[i + 1] + 1] <= 0 ? 1 : 0;
                qp[y[i]][y[i + 1] + 1] = -1;
            }
        }
        System.out.println(yq);
    }
}
